package com.ivo.sec;

import java.io.IOException;

import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ivo.core.WebConstants;
import com.ivo.sys.user.User;
/**
 * 
 *
 * @author Minkey Wang
 * @version 2017年7月12日
 */
public class SessionFilter extends PatternFilter{

	@Override
	public void init(FilterConfig filterConfig) throws ServletException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
		HttpServletRequest request = (HttpServletRequest)req;
//		System.out.println(request.getRequestURI());
		User user = (User) request.getSession().getAttribute(WebConstants.SessionUser);
		SessionLocal.setUser(user);
		chain.doFilter( req, res );
		
	}

	@Override
	public void destroy() {
		// TODO Auto-generated method stub
		
	}

	@Override
	protected void preFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) {
		// TODO Auto-generated method stub
		
	}

}
